package com.wjj.app.fragment.viewpage1;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.Button;
import android.widget.ImageView;

import com.wjj.app.R;


/**
 * Created by Wjj on 16/12/8.
 */
public class FragmentAdd1 extends Fragment {

    private MyInterfaceA mMyInterface;
    private ImageView mIv;
    private Button btn;

    public interface MyInterfaceA {
        void remove();
    }

    public void setListenerA(MyInterfaceA myInterface) {
        this.mMyInterface = myInterface;
    }

    private boolean b = true;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragmentadd, container, false);
        view.findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mMyInterface.remove();
            }
        });

        mIv = (ImageView) view.findViewById(R.id.xuanzhuan_iv);
        btn = (Button) view.findViewById(R.id.start_stop_btn);

        final Animation operatingAnim = AnimationUtils.loadAnimation(getActivity(), R.anim.tip);
        LinearInterpolator lin = new LinearInterpolator();
        operatingAnim.setInterpolator(lin);


        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (b) {

                    mIv.startAnimation(operatingAnim);
                    b=false;
                } else {
                    mIv.clearAnimation();
                    b=true;
                }
            }
        });


        return view;
    }
}
